import os
from gc_analysis import *

with open('processes.txt') as f:
    processes = [l.rstrip() for l in f]
with open('gctypes.txt') as f:
    gctypes = [l.rstrip() for l in f]
with open('windows.txt') as f:
    windows = [int(l.rstrip()) for l in f]
unit_per_sec = 1e7

os.makedirs('out', exist_ok=True)

for process in processes:
    with open('out/' + process + '.txt', 'w') as out:
        for run in range(1000, 1008, 1):
            print(process, run)
            print(run, end='', file=out)
            for w in windows:
                print('\t', w / unit_per_sec, sep='', end='', file=out)
            print(file=out)
            for gctype in gctypes:
                print(gctype, end='', file=out)
                rst = RunningStoppedTimes(parse(str(run) + '/' + gctype + '/gc-' + process + '.log'))
                for w in windows:
                    print('\t', rst.minimum_mutator_time(w) / w, sep='', end='', file=out)
                print(file=out)
            print(file=out)
